<html>
<meta charset="utf-8">
<head>
<script>
var id=0;
var problem=[];
function getQueryVariable(variable)
{
       var query = window.location.search.substring(1);
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
               if(pair[0] == variable){return pair[1];}
       }
       return(false);
}
function button_oc()
{
	var f=new FileReader;
	f.readAsText(file.files[0]);
	f.onload=()=>{problem=JSON.parse(decodeURIComponent(atob(f.result)));main.innerHTML=generateProblem(problem)};
}
function generateProblem(obj)
{
	id=0;
	var html="";
	for(var i in obj)
	{
		html+="<div>";
		html+='<p id="'+i+'">'+obj[i].problem+'</p>';
		html+='<label><input type="radio" name="'+id+'" id="'+id+'t" value="是">是</label>';
		html+='<label><input type="radio" name="'+id+'" id="'+id+'f" value="否">否</label>';
		html+="</div>";
		id++;
	}
	return html;
}
function tijiao_oc(obj)
{
	for(var i in obj)
	{
		ans=(document.getElementsByName(""+i)[0].checked?true:false);
		console.log(ans);
		console.log(obj[i].answer);
		if(ans===obj[i].answer)
		{
			document.getElementById(+i).style.color="lightgreen";
		}
		else
		{
			document.getElementById(+i).style.color="red";
		}
		
	}
}
function daoru_oc()
{
	problem=JSON.parse(decodeURIComponent(atob(T.value)));
	main.innerHTML=generateProblem(problem)
}
</script>
</head>
<body>
<a href="generate.html">生成器</a>
<textarea id="T"></textarea><button onclick="daoru_oc()">从文本导入</button>
导入题目：<input type="file" id="file" name="file" />
<button onclick="button_oc()">导入</button>
<button onclick="tijiao_oc(problem)">核对</button>
<div id="main"></div>
<script>problem=JSON.parse(decodeURIComponent(atob(getQueryVariable("question"))));
main.innerHTML=generateProblem(problem)</script>
</body>
</html>